Skip to content

Prevent IndexError in MethodForm when method registry is empty (fixes #742) - #805

Closed
Aryanban wants to merge 1 commit into
jazzband:masterfrom
Aryanban:fix/method-form-empty-registry-742
Closed

Aryanban wants to merge 1 commit into
jazzband:masterfrom
Aryanban:fix/method-form-empty-registry-742

Conversation

@Aryanban

Copy link
Copy Markdown

Summary

In MethodForm.__init__, self.fields['method'].initial was unconditionally assigned to method.choices[0][0]. When no methods are registered (or when all methods are unregistered), method.choices is an empty list, leading to an unhandled IndexError: list index out of range and crashing the setup wizard when transitioning to the method step.

Fix

  • Guard setting method.initial with if method.choices:.
  • Add unit test in tests/test_forms.py verifying MethodForm initialization with an empty registry.
  • Add unit test in tests/test_views_setup.py verifying SetupView handles an empty registry gracefully without raising an unhandled exception.

Fixes #742.

@moggers87

Copy link
Copy Markdown
Collaborator

As I said here I think it's expected behaviour that the setup view errors if no methods have been configured. I.e. you've mis-configured the app and it will not work.

@moggers87 moggers87 closed this Oct 16, 2026
@Aryanban

Copy link
Copy Markdown
Author

Makes complete sense — thanks for taking a look and clarifying the design rationale!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Setup wizard crashes if registry is empty

2 participants